# $Id$
# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>

pkgbase=phonon
pkgname=('phonon-qt4' 'phonon-qt5')
pkgver=4.9.1
pkgrel=4
arch=('i686' 'x86_64')
url='http://phonon.kde.org/'
license=('LGPL')
makedepends=('extra-cmake-modules' 'automoc4' 'libpulse' 'qt5-base' 'qt5-tools')
source=("http://download.kde.org/stable/${pkgbase}/${pkgver}/${pkgbase}-${pkgver}.tar.xz"{,.sig})
md5sums=('7896a560f5da345a626e782610c8e71e'
         'SKIP')
validpgpkeys=(CB9387521E1EE0127DA804843FDBB55084CC5D84) # Harald Sitter <sitter@kde.org>

prepare() {
  mkdir build
  mkdir build-qt5
}

build() {
  cd build
  cmake ../${pkgbase}-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_SKIP_RPATH=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DPHONON_INSTALL_QT_EXTENSIONS_INTO_SYSTEM_QT=ON \
    -DQT_QMAKE_EXECUTABLE=/usr/bin/qmake-qt4 \
    -D__KDE_HAVE_GCC_VISIBILITY=NO \
    -DCMAKE_INSTALL_LIBDIR=lib
  make

  cd ../build-qt5
  cmake ../${pkgbase}-${pkgver} \
    -DCMAKE_BUILD_TYPE=Release \
    -DCMAKE_SKIP_RPATH=ON \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DPHONON_INSTALL_QT_EXTENSIONS_INTO_SYSTEM_QT=ON \
    -DPHONON_BUILD_PHONON4QT5=ON \
    -D__KDE_HAVE_GCC_VISIBILITY=NO \
    -DCMAKE_INSTALL_LIBDIR=lib
  make
}

package_phonon-qt4(){
  pkgdesc="The multimedia framework for KDE4"
  depends=('qt4' 'libpulse' 'phonon-qt4-backend')
  optdepends=('pulseaudio: PulseAudio support')

  cd build
  make DESTDIR="${pkgdir}" install

  # Install headers into the Qt4 dir
  install -d "${pkgdir}"/usr/include/qt4
  mv "${pkgdir}"/usr/include/{phonon,KDE} "${pkgdir}"/usr/include/qt4/

  sed -i 's#includedir=/usr/include#includedir=/usr/include/qt4#' \
    "${pkgdir}/usr/lib/pkgconfig/phonon.pc"
}

package_phonon-qt5(){
  pkgdesc="The multimedia framework for KF5"
  depends=('libpulse' 'qt5-base' 'phonon-qt5-backend')
  optdepends=('pulseaudio: PulseAudio support')

  cd build-qt5
  make DESTDIR="${pkgdir}" install
}
